<?php 
/* ================================================================================
 * LWAdmin	 
 *
 * users_delete.php: This is where users are deleted.
 *
 * Author: Eric Hendrickson (enhendrickson@liberty.edu)
 * Date: 2/18/05
   ================================================================================ */
	
	global $SSO, $Security, $AppID, $User, $DB;
	//Check to see if there is a valid session 
	$SessionInfo = $SSO->isValidSession("index.php?action=login", $SSO->getSessionInformation());	
	
	//Check to see if the user has rights to be on LWAdmin
	$PageRights = array('ADMIN', 'USERADMIN');
	$Security->ValidateUser($SessionInfo['username'], $AppID, $PageRights, 1);
	
	//Grab the user info
	$UserInfo = $User->GetUserInfo($SessionInfo['username']);
	
	if(isset($_POST['hidden_selUsers']) && $_POST['hidden_selUsers']!="")
	{
		if($_POST['hidden_selUsers'] == $SessionInfo['username'])
		{
			print '<script>alert("You cannot delete yourself!");location.href="index.php?action=users";</script>';
			exit();
		}
		$DB->query("DELETE FROM users WHERE username='" . $_POST['hidden_selUsers'] . "'");
		
		header("Location: index.php?action=users");
	}
	
?>

<table style="border-spacing:0px;border:0px;padding:0px;" width="100%">
	<tr>
		<td>
			<form action="index.php?action=users_delete" method="post" name="frmNewUser">
			<?php 


				if(isset($_POST['selUsers']))
				{

				}


			?>
			<table style="border-spacing:0px;padding:5px;" border="0" align="center">
				<tr>
					<td><br>
					</td>
				</tr>
				<tr>
					<td>
						<span class="TB1">Are you sure you would like to delete the user?</span>
					</td>
				</tr>
				<tr>
					<td><br>
					</td>
				</tr>
				<tr>
					<td align="center">
						<span class="TB1"><?php $DeleteUserInfo = $User->GetUserInfo($_POST['selUsers']); print $DeleteUserInfo['fullname'] . ' (' . $_POST['selUsers'] . ')'; ?></span>
					</td>
				</tr>
				<tr>
					<td><br>
					</td>
				</tr>
				<tr>
					<td align="center">
						<table cellpadding="0" cellspacing="0">
							<tr>
								<td align="center">
									<input name="btnYes" type="submit" value="Yes" class="B"> 
								</td>
								<td>&nbsp;&nbsp;&nbsp;
								</td>
								<td align="center">
									<input name="btnNo" type="button" value="No" class="B" onClick="location.href='index.php?action=users'"> 
									<input name="hidden_selUsers" type="hidden" value="<?php print $_POST['selUsers']; ?>">
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td><br>
					</td>
				</tr>
			</table> 

			</form>
		</td>
	</tr>
</table>